package com.indusfo.spc.controller;

import com.indusfo.spc.pojo.MaintainWork;
import com.indusfo.spc.pojo.MaintainWorkDetail;
import com.indusfo.spc.service.MaintainWorkService;
import com.indusfo.spc.vo.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;

/**
 * 设备保养作业controller
 */
@Controller
@RequestMapping("/service/maintainWork")
public class MaintainWorkController {
    @Resource
    MaintainWorkService maintainWorkService;

    /**
     * 新增设备保养作业
     * @param maintainWork
     * @return
     */
    @ResponseBody
    @RequestMapping("/insertMaintainWork")
    JSONObject insertMaintainWork(MaintainWork maintainWork, Integer[] maintainIds,Integer[] qualifiedIds){
        return maintainWorkService.insertMaintainWork(maintainWork,maintainIds,qualifiedIds);
    }

    /**
     * 查询设备保养作业明细
     * @param maintainWorkDetail
     * @return
     */
    @ResponseBody
    @RequestMapping("/queryMaintainWorkDetail")
    JSONObject queryMaintainWorkDetail(MaintainWorkDetail maintainWorkDetail){
            return maintainWorkService.queryMaintainWorkDetail(maintainWorkDetail);
    }

    /**
     * 编辑设备保养作业
     * @param maintainWork
     * @return
     */
    @ResponseBody
    @RequestMapping("/updateMaintainWork")
    JSONObject updateMaintainWork(MaintainWork maintainWork,Integer[] maintainIds,Integer[] qualifiedIds){
            return maintainWorkService.updateMaintainWorkTain(maintainWork,maintainIds,qualifiedIds);
    }

    /**
     * 审核状态修改
     * @param maintainWorkIds
     * @param auditState
     * @return
     */
    @ResponseBody
    @RequestMapping("/auditStateChange")
    JSONObject auditStateChange(Integer[] maintainWorkIds,Integer auditState,Integer[] auditStateIds){
            return maintainWorkService.auditStateChange(maintainWorkIds,auditState,auditStateIds);
    }

    /**
     * 查询设备保养作业
     * @param maintainWork
     * @return
     */
    @ResponseBody
    @RequestMapping("/queryMaintainWork")
    JSONObject queryMaintainWork(MaintainWork maintainWork,String startDate,String endDate){
        return maintainWorkService.queryMaintainWork(maintainWork,startDate,endDate);
    }

    /**
     * 数据状态修改
     * @param maintainWorkIds
     * @param dataState
     * @return
     */
    @ResponseBody
    @RequestMapping("/defineDataState")
    JSONObject defineDataState(Integer[] maintainWorkIds,Integer dataState,Integer[] auditState){
        return maintainWorkService.defineDataState(maintainWorkIds,dataState,auditState);
    }

    /**
     * 新增设备保养计划明细时查询保养项目
     * @param maintainWork
     * @return
     */
    @ResponseBody
    @RequestMapping("/filterMaintainList")
    JSONObject filterMaintainList(MaintainWork maintainWork,Integer[] maintainIds){
        return maintainWorkService.filterMaintainList(maintainWork,maintainIds);
    }

    /**
     * 查询指定设备的保养项目
     * @param maintainWork
     * @return
     */
    @ResponseBody
    @RequestMapping("/queryMaintainByDeviceOrPlan")
    JSONObject queryMaintainByMaintainWork(MaintainWork maintainWork){
        return maintainWorkService.queryMaintainByMaintainWork(maintainWork);
    }


}
